package evaleto.ecodroid.device;

import android.content.BroadcastReceiver;
import android.content.ContentResolver;
import android.content.Context;
import android.location.LocationManager;
import android.provider.Settings;

public class GPS implements Idevice {
	LocationManager gpsstatus;
	Context context;
	
	public GPS(Context context) {
        gpsstatus = (LocationManager)(context.getSystemService(Context.LOCATION_SERVICE));
        this.context=context;
	}
	
	@Override
	public void addOnChange(BroadcastReceiver receiver) {
	}

	@Override
	public boolean isEnable() {
//        ContentResolver resolver = context.getContentResolver();
//        return Settings.Secure.isLocationProviderEnabled(resolver, LocationManager.GPS_PROVIDER);
        
        return gpsstatus.isProviderEnabled(LocationManager.GPS_PROVIDER);
	}

	@Override
	public void setEnable(boolean enable) {
        ContentResolver resolver = context.getContentResolver();
        Settings.Secure.putInt(resolver, LocationManager.GPS_PROVIDER, enable?0:1);
//        Settings.Secure.setLocationProviderEnabled(resolver, LocationManager.GPS_PROVIDER, !enable);
	}

	@Override
	public void toggle() {
	}

}
